class Admin::HotTagsController < AdminController
  def index
    @hot_tags = HotTag.all.order("sort ASC").page(params[:page]).per(params[:per])
  end

  def new
    @hot_tag = HotTag.new
  end

  def create
    @hot_tag = HotTag.new hot_tag_params
    if @hot_tag.save
      redirect_to admin_hot_tags_path, notice: "保存成功！"
    else
      redirect_to admin_hot_tags_path, notice: "保存失败！"
    end
  end

  def edit
    @hot_tag = HotTag.find params[:id]
  end

  def update
    @hot_tag = HotTag.find params[:id]
    if @hot_tag.update hot_tag_params
      redirect_to admin_hot_tags_path, notice: "更新成功！"
    else
      redirect_to admin_hot_tags_path, notice: "更新失败！"
    end
  end
  
  def destroy
    @hot_tag = HotTag.find params[:id]
    if @hot_tag.destroy
      redirect_to admin_hot_tags_path, notice: "删除成功."
    else
      redirect_to admin_hot_tags_path, notice: "删除失败."
    end
  end

  private

  def hot_tag_params
    params.require(:hot_tag).permit(:name, :sort, :published, :page_url, :page_type, :params)
  end
end
